package ${configure.servicePackage};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import frame.base.BootstrapTable;
<#if id.fieldType == "Integer">
import frame.base.IncrementIdService;
<#elseif id.fieldType == "String">
import frame.base.IncrementIdService;
<#else>
import frame.base.BaseService;
</#if>
import ${configure.entityPackage}.${configure.entityName};
import ${configure.queryPackage}.${configure.queryName};
import ${configure.mapperPackage}.${configure.mapperName};
import tk.mybatis.mapper.common.Mapper;


/**
 * ${configure.modelName} 模块服务类
 * <br>
 * @author ${configure.author}
 * @since ${configure.since}
 */
@Service
<#if id.fieldType == "Integer">
public class ${configure.serviceName} extends IncrementIdService<${configure.entityName}, ${configure.queryName}> {
<#elseif id.fieldType == "String">
public class ${configure.serviceName} extends UUIdService<${configure.entityName}, ${configure.queryName}> {
<#else>
public class ${configure.serviceName} extends BaseService<${id.fieldType}, ${configure.entityName}, ${configure.queryName}> {
</#if>
	@Autowired
    private ${configure.mapperName} ${configure.mapperName?uncap_first};

    @Override
    protected Mapper<${configure.entityName}> mainMapper() {
        return ${configure.mapperName?uncap_first};
    }

    @Override
	public BootstrapTable<${configure.entityName}> pageList(final ${configure.queryName} qo) {
        //分页查询
        Page<${configure.entityName}> page = PageHelper.startPage(qo.page(), qo.size()).doSelectPage(() -> {
            // TODO 分页查询动态条件需要实现
            ${configure.mapperName?uncap_first}.pageList(qo);
        });
        return new BootstrapTable<${configure.entityName}>(page.getTotal(),page.getResult());
	}

    @Override
    protected ${configure.entityName} newInstanceT(${id.fieldType} id) {
        return new ${configure.entityName}(id);
    }
}
